package com.wondersgroup.fjzlpt.org.controller.view.api;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.exception.ServiceException;
import com.wondersgroup.fjzlpt.org.controller.view.jtqy.JtqyController;
import com.wondersgroup.fjzlpt.org.controller.view.model.ModelController;
import com.wondersgroup.fjzlpt.org.dao.inter.jtqy.QyxxDAO;
import com.wondersgroup.fjzlpt.org.service.inter.jtqy.JtqyService;
import com.wondersgroup.fjzlpt.org.service.inter.xymb.XymbService;
import com.wondersgroup.fjzlpt.org.util.ControllerCommonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 第三方使用家庭签约页面
 * <p>
 * <p>
 * Created by sanma on 2017/8/29.
 */
@Controller
@RequestMapping(value = "/api")
public class DsfsyController {

    @Autowired
    private JtqyService jtqyService;

    @Autowired
    private XymbService xymbService;

    @Autowired
    private ModelController modelController;

    @Autowired
    private JtqyController jtqyController;

    @Autowired
    private QyxxDAO qyxxDao;

    @Autowired
    private QyxxDAO qyxxDAO ;

    @RequestMapping("/jtqyApiServer.html")
    public String jtqyApi(HttpServletRequest request){
        Map map = RequestUtils.GetParameterMap(request);

        map.put("FWBZT", "1");
        map.put("TDZT", "1");
        map.put("YLJGID", map.get("PTJGID"));
        JSONObject result = jtqyService.apiQyxxQuery(map);
        request.setAttribute("requestData", result);

        return "api/manager";

    }

    @RequestMapping("/jtqyLsjlApi.html")
    public String jtqyLsjlApi(HttpServletRequest request){
        return modelController.lsjlModel(request);
    }

    @RequestMapping("/jtqyXy.html")
    public String jtqyXy(HttpServletRequest request){
        Map<String, String> map = RequestUtils.GetParameterMap(request);
//        JSONObject json = new JSONObject(3);
//        json.put("YFXM", map.get("XM"));
//        json.put("YFSJHM", map.get("SJHM"));
//        json.put("YFYLJGMC", map.get("YLJGMC"));
//        request.setAttribute("requestData", json);

        //查询启用中的家签协议
        JSONObject jqxyObj = xymbService.queryUseJtqyxy(map);
        request.setAttribute("JQXY_obj", jqxyObj);
        return "api/jtqyXy";
    }

    @RequestMapping("/jtqyXyFwbDetail.html")
    public String jtqyXyFwbDetail(HttpServletRequest request){
        return jtqyController.jtqyXyFwbDetail(request);
    }

    @RequestMapping("/jtqySelectYbfwx.html")
    public String jtqySelectYbfwx(HttpServletRequest request){
        return "api/select_ybfwx";
    }

}
